import xlrd

from common.common_cfig import base_path


def read_excel(file_name, sheet_name, num):
    '''
    :param file_name: 文件名
    :param sheet_name: sheet页名
    :param num: 读取起始行
    :return: 列表套列表的形式
    '''
    file_path = f'{base_path}/test_data/{file_name}'
    workbook = xlrd.open_workbook(file_path)
    table = workbook.sheet_by_name(sheet_name)
    rows = table.nrows
    li = []
    for k in range(num, rows):
        data2 = table.row_values(k)
        li.append(data2)
    return li

def setps_con_kdt( steps_str):
    list_steps = steps_str.splitlines()
    data = []
    for sp in list_steps:
        steps = sp.split()
        dict = {}
        dict["keywords"] = steps.pop(0)
        for sps in steps:
            p = sps.split("=",1)
            dict[p[0]] = p[1]
        data.append(dict)
    return data

if __name__ == '__main__':
    print(read_excel("shunten_shuju.xls", "Sheet1", 1))